package com.dailyblue.smbms.controller;

import com.dailyblue.smbms.service.UserService;
import com.dailyblue.smbms.service.impl.UserServiceImpl;
import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

import java.io.IOException;
import java.io.PrintWriter;

@WebServlet("/user_check_exist")
public class UserCheckExistController extends HttpServlet {

    @Override
    protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String field = request.getParameter("field");
        String value = request.getParameter("value");
        System.out.println(field + "...." + value);
        UserService service = new UserServiceImpl();
        boolean b = service.checkIsUnique(field, value);
        System.out.println(b);
        PrintWriter out = response.getWriter();
        out.println(b);
    }
}